{template 'common/header'}
<ul class="nav nav-tabs nav nav-pills nav-justified">
  <li role="presentation"><a href="{php echo $this->createWebUrl('guaguale')}">刮刮乐管理</a></li>
  <li role="presentation" class="active"><a href="{php echo $this->createWebUrl('prize')}">奖品管理</a></li>
  <li role="presentation"><a href="{php echo $this->createWebUrl('member')}">参与者管理</a></li>
  <li role="presentation"><a href="{php echo $this->createWebUrl('history')}">获奖记录</a></li>
</ul>
{if !$_GPC['operation']}
<div class="main">
<div class="panel panel-info">
		<div class="panel-heading">筛选</div>
		<div class="panel-body">
			<form action="" method="get" class="form-horizontal" role="form">
				<input type="hidden" name="c" value="site" />
				<input type="hidden" name="a" value="entry" />
				<input type="hidden" name="do" value="prize" />
				<input type="hidden" name="m" value="yuan_guaguale" />
				<input type="hidden" name="op" value="prizeselect" />
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">奖品类别</label>
					
					<div class="col-sm-7 col-lg-8 col-xs-12">
						<select class="form-control" name="prizetype" type="text" value="{$_GPC['prizetype']}">
							<option selected="selected"></option>
							<option value='1' {if $prizetype==1}selected="selected"{/if}>虚拟奖品</option>
							<option value='2' {if $prizetype==2}selected="selected"{/if}>实体商品</option>
							<option value='3' {if $prizetype==3}selected="selected"{/if}>卡券</option>
							<option value='4' {if $prizetype==4}selected="selected"{/if}>余额</option>
							<option value='5' {if $prizetype==5}selected="selected"{/if}>积分</option>
						</select>
					</div>		
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">奖品名称</label>
					<div class="col-sm-7 col-lg-8 col-xs-12">
						<input class="form-control" name="prizename" type="text" value="{$prizename}">
					</div>
								
					<div class="pull-right col-lg-2">
						<input type="submit" name="submit" class="btn btn-default" value="搜索">
						<input type="hidden" name="token" value="{$_W['token']}">
					</div>
				</div>
			</form>
		</div>
		</div>		
        <a class="btn btn-primary" href="{php echo $this->createWebUrl('prize', array('operation' => 'add'))}"><i class="icon-plus"></i> 添加奖品</a>
        <div style="padding-top: 15px;"></div>
        <div class="panel panel-default">
            <div class="table-responsive panel-body">
                <table class="table table-hover">
                    <thead class="navbar-inner">
                    <tr>
                        <th style="width:22%;">奖品名称</th>
                        <th style="width:10%;">奖品图片</th>
                        <th style="width:10%;">奖品类型</th>
                        <th style="width:10%;">奖品数量</th>
                        <th style="width:10%;">中奖概率</th>
                        <th style="width:10%;">操作</th>
                    </tr>
                    </thead>
                    <tbody id="level-list">
					{loop $prizelist $item}
                    <tr>
                        <td>{$item['prizename']}</td>
                        <td><img src="{php echo tomedia($item['prizeimgurl'])}" width=100 height=100/></td>
                        <td>{if $item['prizetype']==1}虚拟奖品{/if}{if $item['prizetype']==2}实体商品{/if}{if $item['prizetype']==3}卡券{/if}{if $item['prizetype']==4}余额{/if}{if $item['prizetype']==5}积分{/if}</td>
                        <td>{$item['prizenumber']}</td>
                        <td>{$item['chance']}</td>
                        <td><a href="{php echo $this->createWebUrl('prize',array('operation'=>'update','id'=>$item['id']))}" class="btn btn-primary">编辑</a>
                        	<a href="{php echo $this->createWebUrl('prize',array('operation'=>'delete','id'=>$item['id']))}" class="btn btn-primary" onclick="return confirm('确定将此记录删除?')">删除</a>
                        </td>
                    </tr>
                    {/loop}
                    </tbody>
                                        
                </table>
                {$pager}
            </div>
        </div>
</div>
{/if}
{if $_GPC['operation']=='add'||$_GPC['operation']=='update'}
<form action="{if $_GPC['operation']=='add'}{php echo $this->createWebUrl('prize',array('operation'=>'add','op'=>'additem'))}{/if}{if $_GPC['operation']=='update'}{php echo $this->createWebUrl('prize',array('operation'=>'update','op'=>'updateitem','id'=>$_GPC['id']))}{/if}" method="post" class="form-horizontal form" id="setting-form">
    <div class="panel panel-default">
			<div class="panel-heading">{if $_GPC['operation']=='add'}添加奖品{/if}{if $_GPC['operation']=='update'}修改奖品{/if}</div>
			<div class="panel-body">
				<div class="tab-content">
					<div class="tab-pane active" style="padding:20px;">

                          <div class="form-group">
                                <div class="input-group">
                                    <span class="input-group-addon">奖品名称:</span>
                             
                                    <input type="text" name="prizename" value="{$prizeitem['prizename']}" class="form-control">
                                </div>
                                
                           </div>
                          <div class="form-group">
                                <div class="input-group">
                                    <span class="input-group-addon">奖品图片:</span>
                             		{if $_GPC['operation']=='add'}
                           			{php echo tpl_form_field_image('prizeimgurl')}
                           			{/if}
                             		{if $_GPC['operation']=='update'}
                           			{php echo tpl_form_field_image('prizeimgurl',tomedia($prizeitem['prizeimgurl']))}
                           			{/if}                           			
                                </div>
                                
                           </div>                           
                          <div class="form-group">
                                <div class="input-group">
                                	{if $_GPC['operation']=='add'}
                                    <span class="input-group-addon">奖品类型:</span>
									<select name="prizetype" class="form-control">
									  <option value='1' selected="selected">虚拟奖品</option>
									  <option value='2'>实体商品</option>
									  <option value='3'>卡券</option>
									  <option value='4'>余额</option>
									  <option value='5'>积分</option>
									</select>
									{/if}
									{if $_GPC['operation']=='update'}
									<span class="input-group-addon">奖品类型:</span>
									<select name="prizetype" class="form-control">
										<option selected="selected"></option>
										<option value='1' {if $prizeitem['prizetype']==1}selected="selected"{/if}>虚拟奖品</option>
										<option value='2' {if $prizeitem['prizetype']==2}selected="selected"{/if}>实体商品</option>
										<option value='3' {if $prizeitem['prizetype']==3}selected="selected"{/if}>卡券</option>
										<option value='4' {if $prizeitem['prizetype']==4}selected="selected"{/if}>余额</option>
										<option value='5' {if $prizeitem['prizetype']==5}selected="selected"{/if}>积分</option>
									</select>
									{/if}
                                </div>
                                
                           </div>                           
                          <div class="form-group">
                                <div class="input-group">
                                    <span class="input-group-addon">奖品数量:</span>
                                    <input type="text" name="prizenumber" value="{$prizeitem['prizenumber']}" class="form-control">
                                </div>
                           </div>
                         <div class="form-group">
                                <div class="input-group">
                                    <span class="input-group-addon">中奖概率:</span>
                                    <input type="text" name="chance" value="{$prizeitem['chance']}" class="form-control">
                                </div>
                           </div>
					</div>
					<input type="submit" class="btn btn-primary" value="保存"/>
				</div>
			</div>
		</div>
</form>
{/if}